/*
 * Copyright 2012 alex.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.mkdir.web.controller.felhasznalo;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import javax.faces.bean.ViewScoped;
import javax.inject.Inject;
import javax.inject.Named;
import org.mkdir.ejb.FelhasznaloService;
import org.mkdir.util.Konstans;
import org.mkdir.util.jsf.FacesMessageUtil;
import org.mkdir.util.jsf.MessageBundle;

/**
 *
 * @author alex
 */
@Named
@ViewScoped
public class BeallitasaimController implements Serializable {
    @Inject
    private FelhasznaloService felhasznaloService;
    @Inject
    private FelhasznaloSessionController felhasznaloSessionController;
    private Map<String, String> stilusok;

    public Map<String, String> getStilusok() {
        if (stilusok == null) {
            stilusok = new HashMap<String, String>(Konstans.getStilusok());
        }
        return stilusok;
    }

    public String getValasztottStilus() {
        return felhasznaloSessionController.getFelhasznalo().getStilus();
    }

    public void setValasztottStilus(String valasztottStilus) {
        felhasznaloSessionController.getFelhasznalo().setStilus(valasztottStilus);
    }

    public void modositBeallitasokListener() {
        felhasznaloService.modosit(felhasznaloSessionController.getFelhasznalo());
        felhasznaloSessionController.invalidateFelhasznalo();
        FacesMessageUtil.addInfoMessage(MessageBundle.getMessage("modositva"), MessageBundle.getMessage("beallitasaim"));
    }
}
